﻿
using MaterialDesignThemes.Wpf;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Win32;
using Prism.Commands;
using Prism.DryIoc;
using Prism.Events;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using 基于WPF的电缆采样数据分析系统.Models.CommonUse;
using 基于WPF的电缆采样数据分析系统.Models.Dbs;
using 基于WPF的电缆采样数据分析系统.Models.Dbs.DbService;
using 基于WPF的电缆采样数据分析系统.Models.Enums;
using 基于WPF的电缆采样数据分析系统.Models.FileLogs;
using 基于WPF的电缆采样数据分析系统.Models.RefWav;
using 基于WPF的电缆采样数据分析系统.Models.Task;
using 基于WPF的电缆采样数据分析系统.MsgEvents;
using 基于WPF的电缆采样数据分析系统.MsgEvents.AccountingReport;
using 基于WPF的电缆采样数据分析系统.MsgEvents.DeviceStatus;
using 基于WPF的电缆采样数据分析系统.MsgEvents.HistoricalData;
using 基于WPF的电缆采样数据分析系统.Service;
using 基于WPF的电缆采样数据分析系统.Service.Db;
using 基于WPF的电缆采样数据分析系统.Tools;
using 基于WPF的电缆采样数据分析系统.Tools.LangugeTool;
using 基于WPF的电缆采样数据分析系统.Tools.LogTools;
using 基于WPF的电缆采样数据分析系统.Tools.MessagePopupTool;
using 基于WPF的电缆采样数据分析系统.Tools.ProjectTools;
using 基于WPF的电缆采样数据分析系统.ViewModels.TDRWork;
using 基于WPF的电缆采样数据分析系统.Views.TDRWork;

namespace 基于WPF的电缆采样数据分析系统.ViewModels
{
    public class TDRWorkUCViewModel : BindableBase
    {

        //public static TDRWorkUCViewModel instance = new TDRWorkUCViewModel();

      

        // 常用
        #region 导入波形文件

        /// <summary>
        /// 通道数据
        /// </summary>
        public List<ChannelStatus> ChannelStatusList { get; set; }

        /// <summary>
        /// 初始化通道数据
        /// </summary>
        private void InitChannelStatusList()
        {
            ChannelStatusList = new List<ChannelStatus>();
            ChannelStatusList.Add(new ChannelStatus() { ChannelType = PassageType.ChannelOne });
            ChannelStatusList.Add(new ChannelStatus() { ChannelType = PassageType.ChannelTwo });
            ChannelStatusList.Add(new ChannelStatus() { ChannelType = PassageType.ChannelThree });
        }

        /// <summary>
        /// 导入波形文件命令
        /// </summary>
        public DelegateCommand DRBXWJCmm { get; set; }

        /// <summary>
        /// 导入波形文件方法
        /// </summary>
        private async void DRBXWJFun()
        {
            try
            {

                // 打开对话框
                var result = await DialogHostService.ShowDialog("EditImportWavformChannelUC", null);

                // 添加成功
                if (result.Result == ButtonResult.OK)
                {
                    if (result.Parameters.ContainsKey("ChannelType"))
                    {
                        PassageType passageType = result.Parameters.GetValue<PassageType>("ChannelType");

                        // 赋值日志文件的文件名
                        string[] newStr = result.Parameters.GetValue<string>("FilePath").Split("\\");

                        // 注入通道数据
                        switch (passageType)
                        {
                            case PassageType.ChannelOne:
                                ChannelStatusList[0].FilePath = result.Parameters.GetValue<string>("FilePath");
                                ChannelStatusList[0].IsImportWav = 1;
                                // 添加使用过文件的日志到集合中
                                FileTypeLog.AddUsedFileLogToList(FileType.ImportWaveformFile, newStr[newStr.Length - 1], LangugeConvertor.GetValue("SuccessfullyImportDataToChannelOne"), GlobalVariableEdit.CurrentUserInfo.Uid);
                                // 更新操作日志
                                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("ImportFile") + ": 【" + newStr[newStr.Length - 1] + "】 " + LangugeConvertor.GetValue("SuccessfullyImportDataToChannelOne"));
                                // 更新消息提示
                                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("SuccessfullyImportDataToChannelOne"));

                                // 更新设备状态界面的导入波形次数
                                GlobalVariableEdit.ImportWaveformCount += 1;
                                Aggregator.GetEvent<MsgImportWaveformCountCompute>().Publish();

                                // 更新设备状态界面的文件使用
                                Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

                                // 更新初始通道信息
                                Aggregator.GetEvent<MsgUpdateInitialChannel>().Publish(ChannelStatusList);
                                GlobalVariableEdit.ChannelStatusList = ChannelStatusList;

                                // 更新使用文件记录
                                Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                                // 更新历史数据区
                                Aggregator.GetEvent<MsgHistoryImportWaveformRecords>().Publish();
                                break;
                            case PassageType.ChannelTwo:
                                ChannelStatusList[1].FilePath = result.Parameters.GetValue<string>("FilePath");
                                ChannelStatusList[1].IsImportWav = 1;
                                // 添加使用过文件的日志到集合中
                                FileTypeLog.AddUsedFileLogToList(FileType.ImportWaveformFile, newStr[newStr.Length - 1], LangugeConvertor.GetValue("SuccessfullyImportDataToChannelTwo"), GlobalVariableEdit.CurrentUserInfo.Uid);
                                // 更新操作日志
                                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("ImportFile") + ": 【" + newStr[newStr.Length - 1] + "】 " + LangugeConvertor.GetValue("SuccessfullyImportDataToChannelTwo"));
                                // 更新消息提示
                                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("SuccessfullyImportDataToChannelTwo"));

                                // 更新设备状态界面的导入波形次数
                                GlobalVariableEdit.ImportWaveformCount += 1;
                                Aggregator.GetEvent<MsgImportWaveformCountCompute>().Publish();

                                // 更新设备状态界面的文件使用
                                Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

                                // 更新初始通道信息
                                Aggregator.GetEvent<MsgUpdateInitialChannel>().Publish(ChannelStatusList);
                                GlobalVariableEdit.ChannelStatusList = ChannelStatusList;

                                // 更新使用文件记录
                                Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                                // 更新历史数据区
                                Aggregator.GetEvent<MsgHistoryImportWaveformRecords>().Publish();
                                break;
                            case PassageType.ChannelThree:
                                ChannelStatusList[2].FilePath = result.Parameters.GetValue<string>("FilePath");
                                ChannelStatusList[2].IsImportWav = 1;
                                // 添加使用过文件的日志到集合中
                                FileTypeLog.AddUsedFileLogToList(FileType.ImportWaveformFile, newStr[newStr.Length - 1], LangugeConvertor.GetValue("SuccessfullyImportDataToChannelThree"), GlobalVariableEdit.CurrentUserInfo.Uid);
                                // 更新操作日志
                                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("ImportFile") + ": 【" + newStr[newStr.Length - 1] + "】 " + LangugeConvertor.GetValue("SuccessfullyImportDataToChannelThree"));
                                // 更新消息提示
                                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("SuccessfullyImportDataToChannelThree"));

                                // 更新设备状态界面的导入波形次数
                                GlobalVariableEdit.ImportWaveformCount += 1;
                                Aggregator.GetEvent<MsgImportWaveformCountCompute>().Publish();

                                // 更新设备状态界面的文件使用
                                Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

                                // 更新初始通道信息
                                Aggregator.GetEvent<MsgUpdateInitialChannel>().Publish(ChannelStatusList);
                                GlobalVariableEdit.ChannelStatusList = ChannelStatusList;

                                // 更新使用文件记录
                                Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                                // 更新历史数据区
                                Aggregator.GetEvent<MsgHistoryImportWaveformRecords>().Publish();
                                break;
                        }


                    }
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show("文件报错,原因: " + ex.Message);
                return;
            }

        }

        #endregion


        #region 通道状态
        /// <summary>
        /// 打开通道状态页面命令
        /// </summary>
        public DelegateCommand TDZTCmm { get; set; }

        /// <summary>
        /// 打开通道状态页面方法
        /// </summary>
        private void TDZTFun()
        {
            var paras = new DialogParameters();
            paras.Add("ChannelStatusList", ChannelStatusList);
            var result = DialogHostService.ShowDialog("ChannelStatusUC", paras);
        }
        #endregion


        #region run/stop

        /// <summary>
        /// 停止继续命令
        /// </summary>
        private DelegateCommand _RunOrStopCmm;

        /// <summary>
        /// 停止继续命令
        /// </summary>
        public DelegateCommand RunOrStopCmm
        {
            get { return _RunOrStopCmm; }
            set
            {
                _RunOrStopCmm = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 停止继续方法
        /// </summary>
        private void RunOrStopFun()
        {
            // 未导入波形数据
            if (!(RealTimeOscilloscopeViewModel.Instance.IsImportWav))
            {
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("NoWaveformDataIsImported"));
                return;
            }


            // 之前为继续状态，现在则为停止状态
            if (RealTimeOscilloscopeViewModel.Instance.IsReading)
            {
                RealTimeOscilloscopeViewModel.Instance.IsReading = false;
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("PauseWaveformRefresh"));

                // 更新操作日志
                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("OscilloscopeGraphic") + " " +  LangugeConvertor.GetValue("PauseWaveformRefresh"));
                return;
            }

            // 之前为停止状态，现在则为继续状态
            RealTimeOscilloscopeViewModel.Instance.IsReading = true;
            MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("ContinueWaveformRefresh"));

            // 更新操作日志
            GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("OscilloscopeGraphic") + " " + LangugeConvertor.GetValue("ContinueWaveformRefresh"));
            RealTimeOscilloscopeViewModel.Instance.ToggleContinuationWav(RealTimeOscilloscopeViewModel.Instance.IsReading);
        }

        #endregion


        #region 单次测试
        /// <summary>
        /// 单次测试命令
        /// </summary>
        public DelegateCommand DCCSCmm { get; set; }

        /// <summary>
        /// 单次测试方法
        /// </summary>
        private async void DCCSFun()
        {
            var result = await DialogHostService.ShowDialog("SingleTestUC", null);
            
            if (result.Result == ButtonResult.Yes)
            {
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("SingleTestSuccessful"));

                // 更新操作日志
                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("OscilloscopeGraphic") + " " + LangugeConvertor.GetValue("SingleTestSuccessful"));
            }
        }
        #endregion


        private readonly IEventAggregator Aggregator;

        /// <summary>
        /// 构造器
        /// </summary>
        public TDRWorkUCViewModel(DialogHostService _DialogHostService, IEventAggregator _Aggregator)
        {
            // 初始化左侧任务栏信息
            InitLeftTaskPageInfo();

            // 初始化底部菜单栏信息
            InitBottomMenuPageInfo();

            // 绑定对话框服务
            DialogHostService = _DialogHostService;

            // 绑定发布订阅
            Aggregator = _Aggregator;

            // 常用
            // 绑定导入波形文件命令
            DRBXWJCmm = new DelegateCommand(DRBXWJFun);
            // 绑定通道状态命令
            TDZTCmm = new DelegateCommand(TDZTFun);
            // 绑定run/stop命令
            RunOrStopCmm = new DelegateCommand(RunOrStopFun);
            // 绑定单次测试命令
            DCCSCmm = new DelegateCommand(DCCSFun);

            // 初始化通道数据
            InitChannelStatusList();

            // 工程
            // 绑定新建工程命令
            XJGCCmm = new DelegateCommand(XJGCFun);
            // 绑定打开工程方法
            DKGCCmm = new DelegateCommand(DKGCFun);
            // 绑定导入导出命令
            DCRWCmm = new DelegateCommand(DCRWFun);
            // 绑定保存工程命令
            BCGCCmm = new DelegateCommand(BCGCFun);
            // 绑定另存为命令
            LCWCmm = new DelegateCommand(LCWFun);
            // 绑定最近使用
            ZJSYCmm = new DelegateCommand(ZJSYFun);
            // 绑定切换左侧任务栏状态命令
            ToggleLeftTaskPageCmm = new DelegateCommand(ToggleLeftTaskPageFun);
            // 绑定切换底部菜单栏状态命令
            ToggleBottomMenuPageCmm = new DelegateCommand(ToggleBottomMenuPageFun);

            // 任务
            // 绑定创建任务
            CreateTaskCmm = new DelegateCommand(CreateTaskFun);
            // 绑定编辑任务
            EditTaskCmm = new DelegateCommand(EditTaskFun);
            // 绑定删除任务
            DeleteTaskCmm = new DelegateCommand(DeleteTaskFun);
            // 绑定复制任务
            CopyTaskCmm = new DelegateCommand(CopyTaskFun);
            // 绑定粘贴任务
            PasteTaskCmm = new DelegateCommand(PasteTaskFun);
            // 绑定导出任务
            ExportTaskCmm = new DelegateCommand(ExportTaskFun);

            // 初始化任务描述
            GlobalVariableEdit.TaskContent = LangugeConvertor.GetValue("Nothing");

            // 日志
            // 绑定打印波形
            DYBXCmm = new DelegateCommand(DYBXFun);
            // 绑定打印日志
            DYRZCmm = new DelegateCommand(DYRZFun);
            // 绑定打印设置
            DYSZCmm = new DelegateCommand(DYSZFun);
            // 绑定预览打印波形
            YLDYBXCmm = new DelegateCommand<string>(YLDYBXFun);
            // 绑定预览打印日志
            YLDYRZCmm = new DelegateCommand<string>(YLDYRZFun);
            // 绑定导出表格
            DCBGCmm = new DelegateCommand(DCBGFun);
            // 绑定删除
            SCCmm = new DelegateCommand(SCFun);
            // 绑定删除所有
            SCSYCmm = new DelegateCommand(SCSYFun);
            // 弹出统计
            TCTJCmm = new DelegateCommand(TCTJFun);

            // 波形
            // 绑定坐标范围
            ZBFWCmm = new DelegateCommand(ZBFWFun);
            // 绑定清除波形
            QCBXCmm = new DelegateCommand(QCBXFun);
            // 绑定导出波形
            DCBXCmm = new DelegateCommand(DCBXFun);
            // 绑定保存参考波形
            BCCKBXCmm = new DelegateCommand(BCCKBXFun);
            // 绑定隐藏参考波形
            YCCKBXCmm = new DelegateCommand(YCCKBXFun);
            // 绑定查看所有参考波形
            CKSYCKBXCmm = new DelegateCommand(CKSYCKBXFun);

            // 显示
            // 绑定坐标
            ZBCmm = new DelegateCommand(ZBFun);
            // 绑定容限
            RXCmm = new DelegateCommand(RXFun);
            // 绑定网格
            WGCmm = new DelegateCommand(WGFun);
            // 绑定光标
            GBCmm = new DelegateCommand(GBFun);
            // 绑定十字架实现
            SZJSXCmm = new DelegateCommand(SZJSXFun);
            // 绑定测试信息
            CSXXCmm = new DelegateCommand(CSXXFun);
            // 绑定任务描述
            RWMSCmm = new DelegateCommand(RWMSFun);
            // 绑定水平参考
            SPCKCmm = new DelegateCommand(SPCKFun);

            // 工具
            // 绑定选项
            XXCmm = new DelegateCommand(XXFun);
            // 绑定调试
            TSCmm = new DelegateCommand(TSFun);
            // 绑定串口
            CKCmm = new DelegateCommand(CKFun);
            // 绑定测试定义
            CSDYCmm = new DelegateCommand(CSDYFun);

            // 帮助

            // 绑定TaskPageUCViewModel的实例
            TaskPageUCViewModelInstance = App.GetService<TaskPageUCViewModel>();
        }

        /// <summary>
        /// 对话服务
        /// </summary>
        private readonly DialogHostService DialogHostService;

        // 工程
        #region 新建工程
        public DelegateCommand XJGCCmm { get; set; }

        private TaskPageUCViewModel TaskPageUCViewModelInstance { get; set; }

        /// <summary>
        /// 新建工程
        /// </summary>
        private async void XJGCFun()
        {
            var result = await DialogHostService.ShowDialog("CreateProjectUC", null);

            // 新建工程文件成功
            if (result.Result == ButtonResult.OK)
            {
                if (!result.Parameters.ContainsKey("SelectedFilePath"))
                {
                    return;

                }
                var filePath = result.Parameters.GetValue<string>("SelectedFilePath");
                string[] newStr = filePath.Split("\\");

                // 添加使用过文件的日志到集合中
                FileTypeLog.AddUsedFileLogToList(FileType.ProjectFile, newStr[newStr.Length - 1], LangugeConvertor.GetValue("CreateProjectFile"), GlobalVariableEdit.CurrentUserInfo.Uid);

                // 更新操作日志
                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("CreateProjectFile") + ": 【" + newStr[newStr.Length - 1] + "】");

                // 更新设备状态区的创建工程次数
                GlobalVariableEdit.CreateWaveformCount += 1;
                Aggregator.GetEvent<MsgCreateProjectCountCompute>().Publish();

                // 更新使用文件记录
                Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                var projectDataInfo = OpenProject.ByPathProjectFun(filePath);

                // 添加项目工程日志
                ProjectDataInfoDAOService.Instance.AddProjectDataInfoDAO(GetProjectDataInfoDAO(projectDataInfo, filePath, 1));

                // 更新历史数据区
                Aggregator.GetEvent<MsgHistoricalProjectDocumentation>().Publish();

                // 消息提示
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("CreateProjectSuccessfully"));

                // 成功获取工程对象
                if (projectDataInfo != null)
                {
                    GlobalVariableEdit.CurrentProjectDataInfo = projectDataInfo;

                    TaskPageUCViewModelInstance.CurrentTaskList = GlobalVariableEdit.CurrentProjectDataInfo.TaskList;

                    // 显示波形
                    DefaultSelectedFirstItem(PassageType.ChannelOne);

                    // 清空通道信息
                    ClearChannelInfo();

                    // 添加使用过文件的日志到集合中
                    FileTypeLog.AddUsedFileLogToList(FileType.ProjectFile, newStr[newStr.Length - 1], LangugeConvertor.GetValue("OpenProjectFile"), GlobalVariableEdit.CurrentUserInfo.Uid);

                    // 更新操作日志
                    GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("OpenProjectFile") + ": 【" + newStr[newStr.Length - 1] + "】");

                    // 更新设备状态界面的文件使用
                    Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

                    // 更新使用文件记录
                    Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                    // 添加项目工程日志
                    ProjectDataInfoDAOService.Instance.AddProjectDataInfoDAO(GetProjectDataInfoDAO(projectDataInfo, filePath, 2));

                    // 更新历史数据区
                    Aggregator.GetEvent<MsgHistoricalProjectDocumentation>().Publish();
                }
            }
        }

        /// <summary>
        /// 默认选中第一项
        /// </summary>
        private void DefaultSelectedFirstItem(PassageType channelConfig)
        {
            Aggregator.GetEvent<MsgCreateProjectFirstTaskWav>().Publish();
        }


        /// <summary>
        /// 获取项目工程日志
        /// </summary>
        /// <param name="projectDataInfo"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private ProjectDataInfoDAO GetProjectDataInfoDAO(ProjectDataInfo projectDataInfo, string filePath, int projectType)
        {
            ProjectDataInfoDAO projectDataInfoDAO = new ProjectDataInfoDAO();
            projectDataInfoDAO.ProjectInfo = projectDataInfo.ProjectInfo;
            projectDataInfoDAO.ClientName = projectDataInfo.ClientName;
            projectDataInfoDAO.CreateUser = projectDataInfo.CreateUser;
            projectDataInfoDAO.UpdateUser = projectDataInfo.UpdateUser;
            projectDataInfoDAO.CreateTime = projectDataInfo.CreateTime;
            projectDataInfoDAO.UpdateTime = projectDataInfo.UpdateTime;
            projectDataInfoDAO.FilePath = filePath;
            projectDataInfoDAO.ProjectType = projectType;

            return projectDataInfoDAO;
        }

        #endregion


        #region 打开工程
        /// <summary>
        /// 打开工程命令
        /// </summary>
        public DelegateCommand DKGCCmm { get; set; }

        /// <summary>
        /// 打开工程方法
        /// </summary>
        private void DKGCFun()
        {
            var projectDataInfo = OpenProject.OpenProjectFun();

            // 成功获取工程对象
            if (projectDataInfo != null)
            {

                // 消息提示，获取工程对象成功
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("SucceededInReadProjectFileProcedure"));

                GlobalVariableEdit.CurrentProjectDataInfo = projectDataInfo;

                TaskPageUCViewModelInstance.CurrentTaskList = GlobalVariableEdit.CurrentProjectDataInfo.TaskList;

                // 清空通道信息
                ClearChannelInfo();

                // 赋值日志文件的文件名
                string[] newStr = GlobalVariableEdit.FilePath.Split("\\");

                // 添加使用过文件的日志到集合中
                FileTypeLog.AddUsedFileLogToList(FileType.ProjectFile, newStr[newStr.Length - 1], LangugeConvertor.GetValue("OpenProjectFile"), GlobalVariableEdit.CurrentUserInfo.Uid);

                // 更新操作日志
                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("OpenProjectFile") + ": 【" + newStr[newStr.Length - 1] + "】");

                // 更新设备状态界面的文件使用
                Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

                // 更新使用文件记录
                Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                // 添加项目工程日志
                ProjectDataInfoDAOService.Instance.AddProjectDataInfoDAO(GetProjectDataInfoDAO(projectDataInfo, GlobalVariableEdit.FilePath, 2));

                // 更新历史数据区
                Aggregator.GetEvent<MsgHistoricalProjectDocumentation>().Publish();
            }
        }

        /// <summary>
        /// 清空通道信息
        /// </summary>
        public void ClearChannelInfo()
        {
            Aggregator.GetEvent<MsgClearChannelInfoEvent>().Publish();
        }

        #endregion


        #region 导出任务
        /// <summary>
        /// 导出任务命令
        /// </summary>
        public DelegateCommand DCRWCmm { get; set; }

        /// <summary>
        /// 导出任务方法
        /// </summary>
        private void DCRWFun()
        {
            TaskPageUCViewModelInstance.ExportTaskFun();
        }
        #endregion


        #region 保存工程
        /// <summary>
        /// 保存工程命令
        /// </summary>
        public DelegateCommand BCGCCmm { get; set; }

        /// <summary>
        /// 保存工程方法
        /// </summary>
        private void BCGCFun()
        {
            if (GlobalVariableEdit.CurrentProjectDataInfo == null)
            {
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("WithoutTheProjectItCannotBeSaved"));
                return;
            }

            Aggregator.GetEvent<MsgSaveEvent>().Publish();

            // 更新设备状态界面的文件使用
            Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

            // 更新使用文件记录
            Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

            // 添加项目工程日志
            ProjectDataInfoDAOService.Instance.AddProjectDataInfoDAO(GetProjectDataInfoDAO(GlobalVariableEdit.CurrentProjectDataInfo, GlobalVariableEdit.FilePath, 3));

            // 更新历史数据区
            Aggregator.GetEvent<MsgHistoricalProjectDocumentation>().Publish();
        }
        #endregion


        #region 另存为
        /// <summary>
        /// 另存为方法
        /// </summary>
        public DelegateCommand LCWCmm { get; set; }

        /// <summary>
        /// 另存为方法
        /// </summary>
        private void LCWFun()
        {
            if (GlobalVariableEdit.CurrentProjectDataInfo == null)
            {
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("WithoutTheProjectItCannotBeSaved"));
                return;
            }

            Aggregator.GetEvent<MsgByFileNameSaveEvent>().Publish();

            // 更新设备状态界面的文件使用
            Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

            // 更新使用文件记录
            Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

            // 添加项目工程日志
            ProjectDataInfoDAOService.Instance.AddProjectDataInfoDAO(GetProjectDataInfoDAO(GlobalVariableEdit.CurrentProjectDataInfo, GlobalVariableEdit.FilePath, 3));

            // 更新历史数据区
            Aggregator.GetEvent<MsgHistoricalProjectDocumentation>().Publish();
        }

        #endregion


        #region 最近使用
        /// <summary>
        /// 最近使用命令
        /// </summary>
        public DelegateCommand ZJSYCmm { get; set; }

        /// <summary>
        /// 最近使用方法
        /// </summary>
        private void ZJSYFun()
        {
            TaskPageUCViewModelInstance.RecentUsedFileFun();
        }
        #endregion


        #region 任务栏显示
        /// <summary>
        /// 切换左侧任务栏状态命令
        /// </summary>
        public DelegateCommand ToggleLeftTaskPageCmm { get; set; }

        /// <summary>
        /// 左侧任务栏状态
        /// </summary>
        private bool _LeftTaskPageStatus;

        /// <summary>
        /// 左侧任务栏状态
        /// </summary>
        public bool LeftTaskPageStatus
        {
            get { return _LeftTaskPageStatus; }
            set
            {
                _LeftTaskPageStatus = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 左侧任务栏宽度
        /// </summary>
        private float _LeftTaskPageWidth;

        /// <summary>
        /// 左侧任务栏宽度
        /// </summary>
        public float LeftTaskPageWidth
        {
            get { return _LeftTaskPageWidth; }
            set
            {
                _LeftTaskPageWidth = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 显示任务按钮名字
        /// </summary>
        private string _ShowTaskBtnTxt;

        /// <summary>
        /// 显示任务按钮名字
        /// </summary>
        public string ShowTaskBtnTxt
        {
            get { return _ShowTaskBtnTxt; }
            set
            {
                _ShowTaskBtnTxt = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 切换左侧任务栏状态方法
        /// </summary>
        private void ToggleLeftTaskPageFun()
        {
            LeftTaskPageStatus = !LeftTaskPageStatus;

            if (LeftTaskPageStatus)
            {
                LeftTaskPageWidth = 349;
                ShowTaskBtnTxt = LangugeConvertor.GetValue("TaskHidden");
            }
            else
            {
                LeftTaskPageWidth = 0;
                ShowTaskBtnTxt = LangugeConvertor.GetValue("TaskDisplay");
            }
        }

        /// <summary>
        /// 初始化左侧任务栏信息
        /// </summary>
        private void InitLeftTaskPageInfo()
        {
            LeftTaskPageStatus = true;
            LeftTaskPageWidth = 349;
            ShowTaskBtnTxt = LangugeConvertor.GetValue("TaskHidden");
        }


        #endregion


        #region 菜单栏显示
        /// <summary>
        /// 切换底部菜单栏状态命令
        /// </summary>
        public DelegateCommand ToggleBottomMenuPageCmm { get; set; }

        /// <summary>
        /// 底部菜单栏状态
        /// </summary>
        private bool _BottomMenuPageStatus;

        /// <summary>
        /// 底部菜单栏状态
        /// </summary>
        public bool BottomMenuPageStatus
        {
            get { return _BottomMenuPageStatus; }
            set
            {
                _BottomMenuPageStatus = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 底部菜单栏宽度
        /// </summary>
        private float _BottomMenuPageHeight;

        /// <summary>
        /// 底部菜单栏宽度
        /// </summary>
        public float BottomMenuPageHeight
        {
            get { return _BottomMenuPageHeight; }
            set
            {
                _BottomMenuPageHeight = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 显示菜单按钮名字
        /// </summary>
        private string _ShowMenuBtnTxt = LangugeConvertor.GetValue("MenuHidden");

        /// <summary>
        /// 显示菜单按钮名字
        /// </summary>
        public string ShowMenuBtnTxt
        {
            get { return _ShowMenuBtnTxt; }
            set
            {
                _ShowMenuBtnTxt = value;
                RaisePropertyChanged();
            }
        }



        /// <summary>
        /// 切换底部菜单栏状态方法
        /// </summary>
        private void ToggleBottomMenuPageFun()
        {
            BottomMenuPageStatus = !BottomMenuPageStatus;

            if (BottomMenuPageStatus)
            {
                BottomMenuPageHeight = 240;
                ShowMenuBtnTxt = LangugeConvertor.GetValue("MenuHidden");
            }
            else
            {
                BottomMenuPageHeight = 0;
                ShowMenuBtnTxt = LangugeConvertor.GetValue("MenuDisplay");
            }
        }

        /// <summary>
        /// 初始化底部菜单栏信息
        /// </summary>
        private void InitBottomMenuPageInfo()
        {
            BottomMenuPageStatus = true;
            BottomMenuPageHeight = 240;
            ShowMenuBtnTxt = LangugeConvertor.GetValue("MenuHidden");
        }


        #endregion


        // 任务
        #region 新建任务
        /// <summary>
        /// 新建任务命令
        /// </summary>
        public DelegateCommand CreateTaskCmm { get; set; }

        /// <summary>
        /// 新建任务方法
        /// </summary>
        private void CreateTaskFun()
        {
            TaskPageUCViewModelInstance.CreateTaskFun();
        }
        #endregion


        #region 编辑任务
        /// <summary>
        /// 编辑任务命令
        /// </summary>
        public DelegateCommand EditTaskCmm { get; set; }

        /// <summary>
        /// 编辑任务方法
        /// </summary>
        private void EditTaskFun()
        {
            TaskPageUCViewModelInstance.EditTaskFun();
        }
        #endregion


        #region 删除任务
        /// <summary>
        /// 删除任务命令
        /// </summary>
        public DelegateCommand DeleteTaskCmm { get; set; }

        /// <summary>
        /// 删除任务方法
        /// </summary>
        private void DeleteTaskFun()
        {
            
            TaskPageUCViewModelInstance.DeleteTaskFun();
        }
        #endregion


        #region 复制任务
        /// <summary>
        /// 复制任务命令
        /// </summary>
        public DelegateCommand CopyTaskCmm { get; set; }

        /// <summary>
        /// 复制任务方法
        /// </summary>
        private void CopyTaskFun()
        {
            TaskPageUCViewModelInstance.CopyTaskFun();
        }
        #endregion


        #region 粘贴任务
        /// <summary>
        /// 粘贴任务命令
        /// </summary>
        public DelegateCommand PasteTaskCmm { get; set; }

        /// <summary>
        /// 粘贴任务方法
        /// </summary>
        private void PasteTaskFun()
        {
            TaskPageUCViewModelInstance.PasteTaskFun();
        }
        #endregion


        #region 导出任务
        /// <summary>
        /// 导出任务命令
        /// </summary>
        public DelegateCommand ExportTaskCmm { get; set; }

        /// <summary>
        /// 导出任务方法
        /// </summary>
        private void ExportTaskFun()
        {
            TaskPageUCViewModelInstance.ExportTaskFun();
        }
        #endregion


        // 日志
        #region 打印波形
        /// <summary>
        /// 打印波形命令
        /// </summary>
        public DelegateCommand DYBXCmm { get; set; }

        /// <summary>
        /// 打印波形方法
        /// </summary>
        private void DYBXFun()
        {

        }
        #endregion


        #region 打印日志
        /// <summary>
        /// 打印日志命令
        /// </summary>
        public DelegateCommand DYRZCmm { get; set; }

        /// <summary>
        /// 打印日志方法
        /// </summary>
        private void DYRZFun()
        {

        }
        #endregion


        #region 打印设置
        /// <summary>
        /// 打印设置命令
        /// </summary>
        public DelegateCommand DYSZCmm { get; set; }

        /// <summary>
        /// 打印设置方法
        /// </summary>
        private void DYSZFun()
        {

        }
        #endregion


        #region 预览打印波形
        /// <summary>
        /// 预览打印波形命令
        /// </summary>
        public DelegateCommand<string> YLDYBXCmm { get; set; }

        /// <summary>
        /// 预览打印波形方法
        /// </summary>
        private void YLDYBXFun(string title)
        {
            var paras = new DialogParameters();
            paras.Add("title", title);
            var result = DialogHostService.ShowDialog("PreviewPrintUC", paras);
        }
        #endregion


        #region 预览打印日志
        /// <summary>
        /// 预览打印日志命令
        /// </summary>
        public DelegateCommand<string> YLDYRZCmm { get; set; }

        /// <summary>
        /// 预览打印日志方法
        /// </summary>
        private void YLDYRZFun(string title)
        {
            var paras = new DialogParameters();
            paras.Add("title", title);
            var result = DialogHostService.ShowDialog("PreviewPrintUC", paras);
        }

        #endregion


        #region 导出表格
        /// <summary>
        /// 导出表格命令
        /// </summary>
        public DelegateCommand DCBGCmm { get; set; }

        /// <summary>
        /// 导出表格方法
        /// </summary>
        private void DCBGFun()
        {

        }
        #endregion


        #region 删除
        /// <summary>
        /// 删除命令
        /// </summary>
        public DelegateCommand SCCmm { get; set; }

        /// <summary>
        /// 删除方法
        /// </summary>
        private void SCFun()
        {

        }
        #endregion


        #region 删除所有
        /// <summary>
        /// 删除所有命令
        /// </summary>
        public DelegateCommand SCSYCmm { get; set; }

        /// <summary>
        /// 删除所有方法
        /// </summary>
        private void SCSYFun()
        {

        }

        #endregion


        #region 弹出统计
        /// <summary>
        /// 弹出统计命令
        /// </summary>
        public DelegateCommand TCTJCmm { get; set; }

        /// <summary>
        /// 弹出统计方法
        /// </summary>
        private void TCTJFun()
        {

        }
        #endregion


        // 波形
        #region 坐标范围
        /// <summary>
        /// 坐标范围命令
        /// </summary>
        public DelegateCommand ZBFWCmm { get; set; }

        /// <summary>
        /// 坐标范围方法
        /// </summary>
        private void ZBFWFun()
        {
            var result = DialogHostService.ShowDialog("CoordinateRangeUC", null);
        }
        #endregion


        #region 清除波形
        /// <summary>
        /// 清除波形命令
        /// </summary>
        public DelegateCommand QCBXCmm { get; set; }

        /// <summary>
        /// 清除波形方法
        /// </summary>
        private void QCBXFun()
        {
            if (!(RealTimeOscilloscopeViewModel.Instance.IsImportWav))
            {
                // 消息提示
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("NoWaveformDataIsImported"));
                return;
            }

            RealTimeOscilloscopeViewModel.Instance.ClearWavform();

            // 消息提示
            MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("WaveformClearedSuccessfully"));

            // 更新操作日志
            GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("WaveformClearedSuccessfully"));
        }

        #endregion


        #region 导出波形
        /// <summary>
        /// 导出波形命令
        /// </summary>
        public DelegateCommand DCBXCmm { get; set; }

        /// <summary>
        /// 导出波形方法
        /// </summary>
        private async void DCBXFun()
        {
            var result = await DialogHostService.ShowDialog("ExportWavformUC", null);

            if (result.Result == ButtonResult.Yes)
            {
                if (result.Parameters.ContainsKey("retResult"))
                {
                    if (result.Parameters.GetValue<RetResult>("retResult") == RetResult.Success)
                    {
                        MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("ExportFileSuccessfully"));

                        // 更新设备状态区的导出波形次数
                        GlobalVariableEdit.ExportWaveformCount += 1;
                        Aggregator.GetEvent<MsgExportWaveformCountCompute>().Publish();

                        // 更新设备状态界面的文件使用
                        Aggregator.GetEvent<MsgFileUsedStatus>().Publish();

                        // 更新使用文件记录
                        Aggregator.GetEvent<MsgUpdateShowUsedFileLogList>().Publish();

                    } else if (result.Parameters.GetValue<RetResult>("retResult") == RetResult.Fail)
                    {
                        MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("TheExportFileHasBeenCancelled"));
                    }
                }
                
            }
        }
        #endregion


        #region 保存参考波形
        /// <summary>
        /// 保存参考波形命令
        /// </summary>
        public DelegateCommand BCCKBXCmm { get; set; }

        /// <summary>
        /// 保存参考波形方法
        /// </summary>
        private async void BCCKBXFun()
        {
            var result = await DialogHostService.ShowDialog("SaveReferenceWaveformUC", null);

            if (result.Result == ButtonResult.Yes)
            {
                MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("ReferenceWaveformHasBeenSaved"));


                GlobalVariableEdit.CurrentRefWav = result.Parameters.GetValue<RefWavformType>("CurrentRefWavform");

                // 更新操作日志
                GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("ReferenceWaveformHasBeenSaved") + ": 【" + GlobalVariableEdit.CurrentRefWav + "】");

                List<ReferenceWaveform> CurrentRefWavList = result.Parameters.GetValue<List<ReferenceWaveform>>("CurrentRefWavformList");

                // 参考波形信息修改
                RefWavInfoUpdate(CurrentRefWavList);

                // 保存参考波形的波形数据
                Aggregator.GetEvent<MsgSaveRefWavData>().Publish();

                // 更新到通道界面
                Aggregator.GetEvent<MsgSaveRefWavStatus>().Publish();

                // 显示保存的参考波形
                for (int i = 0; i < CurrentRefWavList.Count; i++)
                {
                    if (CurrentRefWavList[i].RDisplayStatus)
                    {
                        UpdateRefWavDisplay(CurrentRefWavList[i].R);
                        RealTimeOscilloscopeViewModel.Instance.ByTypeDisplayRefWavform(CurrentRefWavList[i].R);
                    }
                }

                // 更新参考波形信息
                Aggregator.GetEvent<MsgUpdateReferenceWaveform>().Publish();
            }
        }

        /// <summary>
        /// 修改参考波形是否显示
        /// </summary>
        /// <param name="R"></param>
        private void UpdateRefWavDisplay(RefWavformType R)
        {
            switch (R)
            {
                case RefWavformType.RefWavformOne:
                    GlobalVariableEdit.R1Display = true;
                    break;
                case RefWavformType.RefWavformTwo:
                    GlobalVariableEdit.R2Display = true;
                    break;
                case RefWavformType.RefWavformThree:
                    GlobalVariableEdit.R3Display = true;
                    break;
                case RefWavformType.RefWavformFour:
                    GlobalVariableEdit.R4Display = true;
                    break;
                case RefWavformType.RefWavformFive:
                    GlobalVariableEdit.R5Display = true;
                    break;
                case RefWavformType.RefWavformSix:
                    GlobalVariableEdit.R6Display = true;
                    break;
                case RefWavformType.RefWavformSeven:
                    GlobalVariableEdit.R7Display = true;
                    break;
                case RefWavformType.RefWavformEight:
                    GlobalVariableEdit.R8Display = true;
                    break;
            }
        }

        /// <summary>
        /// 参考波形信息修改
        /// </summary>
        private void RefWavInfoUpdate(List<ReferenceWaveform> CurrentRefWavformList)
        {
            // 波形别名
            GlobalVariableEdit.R1Name = CurrentRefWavformList[0].RName;
            GlobalVariableEdit.R2Name = CurrentRefWavformList[1].RName;
            GlobalVariableEdit.R3Name = CurrentRefWavformList[2].RName;
            GlobalVariableEdit.R4Name = CurrentRefWavformList[3].RName;
            GlobalVariableEdit.R5Name = CurrentRefWavformList[4].RName;
            GlobalVariableEdit.R6Name = CurrentRefWavformList[5].RName;
            GlobalVariableEdit.R7Name = CurrentRefWavformList[6].RName;
            GlobalVariableEdit.R8Name = CurrentRefWavformList[7].RName;

            // 波形显示
            GlobalVariableEdit.R1Display = CurrentRefWavformList[0].RDisplayStatus;
            GlobalVariableEdit.R2Display = CurrentRefWavformList[1].RDisplayStatus;
            GlobalVariableEdit.R3Display = CurrentRefWavformList[2].RDisplayStatus;
            GlobalVariableEdit.R4Display = CurrentRefWavformList[3].RDisplayStatus;
            GlobalVariableEdit.R5Display = CurrentRefWavformList[4].RDisplayStatus;
            GlobalVariableEdit.R6Display = CurrentRefWavformList[5].RDisplayStatus;
            GlobalVariableEdit.R7Display = CurrentRefWavformList[6].RDisplayStatus;
            GlobalVariableEdit.R8Display = CurrentRefWavformList[7].RDisplayStatus;
        }
        #endregion


        #region 隐藏参考波形
        /// <summary>
        /// 隐藏参考波形命令
        /// </summary>
        public DelegateCommand YCCKBXCmm { get; set; }

        /// <summary>
        /// 隐藏参考波形方法
        /// </summary>
        private void YCCKBXFun()
        {
            // 通知
            MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("AllReferenceWaveformsAreHidden"));

            if (GlobalVariableEdit.R1Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformOne);
            }
            
            if (GlobalVariableEdit.R2Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformTwo);
            }
            
            if (GlobalVariableEdit.R3Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformThree);
            }
            
            if (GlobalVariableEdit.R4Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformFour);
            }
            
            if (GlobalVariableEdit.R5Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformFive);
            }
            
            if (GlobalVariableEdit.R6Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformSix);
            }
            
            if (GlobalVariableEdit.R7Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformSeven);
            }
            
            if (GlobalVariableEdit.R8Display)
            {
                RealTimeOscilloscopeViewModel.Instance.HiddenRefWavform(RefWavformType.RefWavformEight);
            }

            // 更新到通道界面
            Aggregator.GetEvent<MsgSaveRefWavStatus>().Publish();

            // 更新操作日志
            GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("AllReferenceWaveformsAreHidden"));
        }
        #endregion


        #region 查看所有参考波形
        /// <summary>
        /// 查看所有参考波形命令
        /// </summary>
        public DelegateCommand CKSYCKBXCmm { get; set; }

        /// <summary>
        /// 查看所有参考波形方法
        /// </summary>
        private void CKSYCKBXFun()
        {
            // 通知
            MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("DisplaysAllReferenceWaveforms"));

            // 波形显示
            GlobalVariableEdit.R1Display = true;
            GlobalVariableEdit.R2Display = true;
            GlobalVariableEdit.R3Display = true;
            GlobalVariableEdit.R4Display = true;
            GlobalVariableEdit.R5Display = true;
            GlobalVariableEdit.R6Display = true;
            GlobalVariableEdit.R7Display = true;
            GlobalVariableEdit.R8Display = true;

            // 更新到通道界面
            Aggregator.GetEvent<MsgSaveRefWavStatus>().Publish();

            // 更新操作日志
            GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("DisplaysAllReferenceWaveforms"));
        }
        #endregion


        // 显示
        #region 坐标
        public DelegateCommand ZBCmm { get; set; }

        private void ZBFun()
        {

        }

        #endregion


        #region 容限
        public DelegateCommand RXCmm { get; set; }

        private void RXFun()
        {

        }
        #endregion


        #region 网格
        public DelegateCommand WGCmm { get; set; }

        private void WGFun()
        {

        }
        #endregion


        #region 光标
        public DelegateCommand GBCmm { get; set; }

        private void GBFun()
        {

        }
        #endregion


        #region 十字架实线
        public DelegateCommand SZJSXCmm { get; set; }

        private void SZJSXFun()
        {

        }
        #endregion


        #region 测试信息
        public DelegateCommand CSXXCmm { get; set; }

        private void CSXXFun()
        {

        }
        #endregion


        #region 任务描述
        public DelegateCommand RWMSCmm { get; set; }

        private void RWMSFun()
        {

        }
        #endregion


        #region 水平参考
        public DelegateCommand SPCKCmm { get; set; }

        private void SPCKFun()
        {

        }
        #endregion


        // 工具
        #region 选项
        /// <summary>
        /// 选项命令
        /// </summary>
        public DelegateCommand XXCmm { get; set; }

        /// <summary>
        /// 选项方法
        /// </summary>
        private async void XXFun()
        {
            var result = await DialogHostService.ShowDialog("OptionUC", null);

            if (result.Result == ButtonResult.Yes)
            {
                if (result.Parameters.ContainsKey("CurrentSelectedLanguge"))
                {
                    var langugeType = result.Parameters.GetValue<LangugeType>("CurrentSelectedLanguge");

                    try
                    {
                        if (langugeType == LangugeType.Chinese)
                        {
                            string chinese = "pack://application:,,,/基于WPF的电缆采样数据分析系统;component/Languge/cn.xaml";
                            Application.Current.Resources.MergedDictionaries[4].Source = new Uri(chinese);

                            // 更新操作日志
                            GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("LanguageChangeToChinese"));
                        }

                        if (langugeType == LangugeType.English)
                        {
                            string english = "pack://application:,,,/基于WPF的电缆采样数据分析系统;component/Languge/en.xaml";
                            Application.Current.Resources.MergedDictionaries[4].Source = new Uri(english);

                            // 更新操作日志
                            GlobalLogTool.Instance.AddLogToTDRWork(GlobalVariableEdit.CurrentUserInfo.Uid, LangugeConvertor.GetValue("LanguageChangeToEnglish"));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessagePopup.DisplayMessagePopup(LangugeConvertor.GetValue("ThereIsAnExceptionInSwitchingLanguages"));
                    }
                }
            }
        }
        #endregion


        #region 调试
        /// <summary>
        /// 调试命令
        /// </summary>
        public DelegateCommand TSCmm { get; set; }

        /// <summary>
        /// 调试方法
        /// </summary>
        private void TSFun()
        {
            var result = DialogHostService.ShowDialog("DebugUC", null);

        }
        #endregion


        #region 串口
        /// <summary>
        /// 串口命令
        /// </summary>
        public DelegateCommand CKCmm { get; set; }

        /// <summary>
        /// 串口方法
        /// </summary>
        private void CKFun()
        {

        }
        #endregion


        #region 测试定义
        /// <summary>
        /// 测试定义命令
        /// </summary>
        public DelegateCommand CSDYCmm { get; set; }

        /// <summary>
        /// 测试定义方法
        /// </summary>
        private void CSDYFun()
        {
            var result = DialogHostService.ShowDialog("TestDefineUC", null);

        }
        #endregion


        // 帮助

    }
}
